<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <script src="https://unpkg.com/axios/dist/axios.min.js"></script>
  <title>Document</title>
</head>
<style>
  * {
    margin: 0;
    padding: 0;
  }

  .home {
    font-size: 0.45rem;
    padding: 0.3rem;
  }

  .btn {
    display: flex;
    justify-content: center;
    margin-top: 5rem;

  }

  .default {
    border: 1px solid #54b6ab;
    padding: 0.3rem;

    margin-right: 0.5rem;
    width: 3rem;
    text-align: center;
    border-radius: 0.2rem;
    color: #54b6ab;
  }

  .confirm {
    background-color: #54b6ab;
    color: #fff;
  }

  .reminder {
    background: #54b6ab;
    text-align: center;
    color: #fff;
    padding: 1rem;
    font-size: 0.8rem;
    border-radius: 0.3rem;
    margin-top: 3rem;
  }
</style>

<body>
  <div class="home">
    <div class="reminder"></div>
    <div class="btn">
      <div class="default">
        不同意
      </div>
      <div class="default confirm">
        同意
      </div>

    </div>

  </div>

</body>
<script>
  const urlParams = new URLSearchParams(window.location.search)
  const requestId = urlParams.get('requestId')
  const familyMemberId = urlParams.get('familyMemberId')
  var confirmbtn = document.querySelector('.confirm')
  var reminder = document.querySelector('.reminder')
  let managedByPersonName = ''
  let userId = ''

  confirmbtn.addEventListener('click', function () {
    let param = {
      userId: userId,
      healthManageConfirmRequestId: requestId,
      agree: "yes", //yes,no
      allowedPermissions: [] //允许的授权，精细话管理授权，目前为空
    }
    axios.post('https://zg.particlesoft.info//frontend/filing/v1/api/healthManageRequest/confirm', param).then(
      res => {
        alert('成功')
      })
  })

  function perinfo() {
    axios.get(
        `https://zg.particlesoft.info/frontend/filing/v1/api/healthManage/healthManageConfirmRequest?id=${requestId}`)
      .then(
        res => {
          console.log(res)
          managedByPersonName = res.data.data.managedByPersonName
          reminder.innerHTML = `您是否同意${managedByPersonName}管理您的个人信息`
        })
    axios.get(`https://zg.particlesoft.info/frontend/filing/v1/api/userInfo/wechat?familyMemberId=${familyMemberId}`)
      .then(
        res => {
          console.log(res)
          userId = res.data.data.userId
        })
  }

  function getWindowInfo() {
    var width = window.innerWidth
    var higth = window.innerHeight
    document.querySelector('html').style.fontSize = width / 20 + 'px'
    console.log(width)
  }
  // 监听页面改变
  function listenResize() {
    window.addEventListener('resize', getWindowInfo)

  }
  perinfo()
  getWindowInfo()
  listenResize()
</script>

</html>